//
//  UserView.m
//  练习
//
//  Created by hcios on 2017/7/5.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "UserView.h"

#define FONT_NAME_LTH                   @"FZLanTingHeiS-R-GB"

#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width


@implementation UserView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setUpSubViews];
    }
    return self;
}


-(void)setUpSubViews{
    
    self.userInteractionEnabled = YES;
    CGFloat padding = 10;
    
    //头像
    _authorImage = [[UIImageView alloc] init];
    [_authorImage setFrame:CGRectMake(padding, padding, 40, 40)];
    _authorImage.layer.masksToBounds = YES;
    _authorImage.layer.cornerRadius = 20;
    _authorImage.layer.borderWidth = 2;
    _authorImage.layer.borderColor = [UIColor whiteColor].CGColor;
    [self addSubview:_authorImage];
    
    //姓名
    _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_authorImage.frame) + 5, padding, SCREEN_WIDTH - 160, 20)];
    [_nameLabel setFont:[UIFont fontWithName:FONT_NAME_LTH size:15]];
    [_nameLabel setTextColor:[UIColor blackColor]];
    [self addSubview:_nameLabel];
    
    //游记
    _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_authorImage.frame) + 5, CGRectGetMaxY(_nameLabel.frame) + 5, SCREEN_WIDTH - 160, 20)];
    [_countLabel setTextColor:[UIColor blackColor]];
    [_countLabel setFont:[UIFont fontWithName:FONT_NAME_LTH size:11]];
    [self addSubview:_countLabel];
    
    
    //关注
    _seebtn = [[UIButton alloc] initWithFrame:CGRectMake(self.frame.size.width - 100, padding + 5, 80, 30)];
    [_seebtn setTitle:@"+ 关注" forState:UIControlStateNormal];
    [_seebtn setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    [_seebtn.titleLabel setFont:[UIFont fontWithName:FONT_NAME_LTH size:13]];
    _seebtn.layer.borderWidth = 1;
    _seebtn.layer.borderColor = [UIColor blackColor].CGColor;
     [_seebtn addTarget:self action:@selector(attention:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_seebtn];
}


//关注方法
-(void)attention:(id)sender{
    NSLog(@"点击关注");
    if (self.delegate && [self.delegate respondsToSelector:@selector(gzBtn:)]) {
        [self.delegate gzBtn:sender];
    }
}

@end
